package com.zhl.media.app.utils;

import android.content.Context;

import com.zhl.media.app.greendao.DaoMaster;
import com.zhl.media.app.greendao.DaoSession;

public class DaoManager {
    private static DaoManager mInstance;
    private DaoMaster mDaoMaster;
    private DaoSession mDaoSession;
    private DaoManager(Context context) {
        DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(context, "zhlgrd", null);
        mDaoMaster = new DaoMaster(devOpenHelper.getWritableDatabase());
        mDaoSession = mDaoMaster.newSession();
    }

    public DaoMaster getMaster() {
        return mDaoMaster;
    }

    public DaoSession getSession() {
        return mDaoSession;
    }

    public static DaoManager getInstance(Context context) {
        if (mInstance == null) {
            mInstance = new DaoManager(context);
        }
        return mInstance;
    }
}